<template>
	<view>
		<view class="bus_info tp-w690">
			<view class="info_top-wrap">
				<view class="date">
					<text class="type">班车</text>
					发车时间：{{dateInfo.startDay}}
				</view>
				<view class="status">
					<view v-if="dateInfo.status==0">待支付</view>
					<view v-else>
						<text v-if="dateInfo.status==1">待使用</text>
						<text v-if="dateInfo.status==2">出行中</text>
						<text v-if="dateInfo.status==3">待评价</text>
						<text v-if="dateInfo.status==4">已完成</text>
						<text v-if="dateInfo.status==5">已退票</text>
						<text v-if="dateInfo.status==6">已结束</text>
					</view>
				</view>
			</view>
			<view class="info_content-wrap" @click="handleGoBusOrderDetail(dateInfo)">
				<view class="from">
					<text class="time">{{dateInfo.departureTime}}</text>
					<text class="address">{{dateInfo.startStation}}</text>
				</view>
				<view class="bus_type-wrap">
					<text class="but_type">{{dateInfo.shiftsCartype}}</text>
					<view class="dack"></view>
					<text class="duration">历时{{dateInfo.travelTime}}分钟</text>
				</view>
				<view class="to">
					<text class="time">{{dateInfo.arriveTime}}</text>
					<text class="address">{{dateInfo.arriveStation}}</text>
				</view>

				<image v-if="dateInfo.type==1" class="dack-img" src="../../pagesUser/static/toandfor-icon.png"></image>
			</view>
			<view class="order_info-wrap">
				<view class="order_num">订单号：{{dateInfo.orderNo}}</view>
				<view class="btns">
					<view v-if="dateInfo.status == 0" class="btn cancle" @click="handleCancleOrder">取消</view>
					<view v-if="dateInfo.status != 0" class="btn cancle" @click="handleDelOrder">删除</view>
					<view v-if="dateInfo.status == 0" class="btn pay" @click="handlePay">支付</view>
					<!-- </view>
				<view class="btns"> -->
					<view v-if="dateInfo.status==3" class="btn pay" @click="handleGoBusOrderDetail(dateInfo)">打分评价</view>
					<view v-if="dateInfo.status==4" class="btn pay" @click="handleGoBusOrderDetail(dateInfo)">查看评价</view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		components: {},
		props: {
			dateInfo: {
				type: Object,
				default () {
					return {}
				}
			},
			curNavbar: {
				type: [Object, Boolean],
				default () {
					return false
				}
			},
			hideBtn: {
				type: Boolean,
				default () {
					return false
				}
			}
		},
		data() {
			return {};
		},
		mounted() {

		},
		methods: {
			handlePay() {
				const _this = this
				// #ifdef MP-WEIXIN
				uni.requestSubscribeMessage({
					tmplIds: ['p08IN_BfeNZu8QEIasbY-BrW-sgyEX1z-4mW3BPE7P0'],
					success(res) {
						_this.submitWxNotifyConfirm('p08IN_BfeNZu8QEIasbY-BrW-sgyEX1z-4mW3BPE7P0', res[
							'p08IN_BfeNZu8QEIasbY-BrW-sgyEX1z-4mW3BPE7P0'])
						// #endif
						uni.$emit('showCommonPay', _this.dateInfo)
						// #ifdef MP-WEIXIN
					}
				})
				// #endif
			},
			handleCancleOrder() {
				uni.$emit('showConfirmCancleOrderAlert', this.dateInfo)
			},
			handleDelOrder() {
				uni.$emit('showConfirmDelOrderAlert', this.dateInfo)
			},
			handleGoBusOrderDetail(data) {
				let {
					type
				} = data
				if (type == 0) { // 单程
					uni.navigateTo({
						url: '../../pagesUser/order/bus.orderDetail?id=' + data.orderNo + '&hideBtn=' + this.hideBtn + '&status=' +
							data.status
					});
				} else if (type == 1) { // 往返程
					uni.navigateTo({
						url: '../../pagesUser/order/bus.orderDetail?id=' + data.orderNo + '&hideBtn=' + this.hideBtn + '&toAndFor=true' +
							'&status=' + data.status
					});
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.bus_info {
		background: #fff;
		border-radius: 12rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		margin-bottom: 20rpx;

		.info_top-wrap {
			height: 80rpx;
			display: flex;
			align-items: center;
			font-size: 26rpx;
			justify-content: space-between;
			padding: 0 20rpx;

			.date {
				color: #666;
				display: flex;
				align-items: center;

				.type {
					display: inline-block;
					width: 66rpx;
					height: 40rpx;
					line-height: 40rpx;
					text-align: center;
					background-color: #FFF2E0;
					color: $yellow;
					font-size: 22rpx;
					margin-right: 20rpx;
					border-radius: 8rpx;
				}
			}

			.status {
				color: $yellow;
			}
		}

		.info_content-wrap {
			display: flex;
			flex: 1;
			justify-content: space-between;
			padding: 40rpx;
			border-top: 1px solid #EBEBEB;
			border-bottom: 1px solid #EBEBEB;
			position: relative;

			.dack-img {
				position: absolute;
				top: 0;
				right: 0;
				z-index: 2;
				height: 80rpx;
				width: 80rpx;
			}

			.from,
			.to {
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				line-height: 1;
				height: 100rpx;

				.time {
					font-size: 48rpx;
					font-weight: bold;
				}

				.address {
					font-size: 32rpx;
				}
			}

			.to {
				text-align: right;
			}

			.bus_type-wrap {
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				font-size: 24rpx;
				color: #666;
				height: 100rpx;

				.dack {
					width: 170rpx;
					background-color: #ccc;
					height: 6rpx;
					position: relative;

					&::before {
						content: '';
						position: absolute;
						width: 35rpx;
						height: 6rpx;
						top: -11rpx;
						right: -7rpx;
						background-color: #ccc;
						transform: rotate(45deg);
					}
				}
			}
		}

		.order_info-wrap {
			height: 95rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			color: #666;
			padding: 0 20rpx;

			.order_num {
				font-size: 26rpx;
			}

			.btns {
				display: flex;
				align-items: center;
				justify-content: flex-end;

				.btn {
					border-radius: 12rpx;
					padding: 0 15rpx;
					height: 56rpx;
					line-height: 56rpx;
					text-align: center;
					min-width: 78rpx;
					font-size: 28rpx;

					&.cancle {
						background-color: #EBEBEB;
					}

					&.pay {
						color: #fff;
						background-color: $blue;
						margin-left: 20rpx;
					}
				}
			}
		}
	}
</style>
